package com.zhdl.common.enums;

/**
 * 表达式条件类型
 *
 * @Description:
 * @author: liu zhenming
 * @date: 2023/6/27 10:38
 */
public enum ConditionEnum {

    /**
     * 1:   mechanism
     * 2:   flow_condition_through
     * 3:   flow_front_block_extend
     * 4:   flow_line_through
     * 5:   flow_element_through
     * 6:   parts_state_value_standard
     */
    MECHANISM(1),
    FLOW_CONDITION_THROUGH(2),
    FLOW_FRONT_BLOCK_EXTEND(3),
    FLOW_LINE_THROUGH(4),
    FLOW_ELEMENT_THROUGH(5),
    PARTS_STATE_VALUE_STANDARD(6);

    private final int type;

    ConditionEnum(int type) {
        this.type = type;
    }

    public static ConditionEnum fromType(String type) {
        // 根据类型值获取对应的枚举值
        int count = Integer.parseInt(type);

        ConditionEnum[] enums = values();
        for (ConditionEnum conditionEnum : enums) {
            if (conditionEnum.type == count) {
                return conditionEnum;
            }
        }
        throw new RuntimeException("错误的ConditionEnum类型");
    }

    public int getType() {
        return type;
    }
}
